package made.ann;

public class Neuron
{

    private int numIn;
    private float[] _weights;
    private float[] _weightGradients;
    private float[] _accWeights;
    private float[] _previousWeightDeltas;
    private float _sumGradient;
    private float _output;

    // Constructor for input neurons
    public Neuron()
    {
        numIn = 0;
        _weights = null;
        _weightGradients = null;
        _accWeights = null;
        _previousWeightDeltas = null;
        _sumGradient = 0.0f;
        _output = 0.0f;
    }

    // Constructor for hidden and output neurons
    public Neuron(int n)
    {
        numIn = n;
        _weights = new float[numIn];
        _weightGradients = new float[numIn];
        _accWeights = new float[numIn];
        _previousWeightDeltas = new float[numIn];

        for (int i = 0; i < numIn; i++)
        {
            _weights[i] = 0.0f;
            _weightGradients[i] = 0.0f;
            _accWeights[i] = 0.0f;
            _previousWeightDeltas[i] = 0.0f;
        }

        _sumGradient = 0.0f;
        _output = 0.0f;
    }

    public float getWeight(int idx)
    {
        return _weights[idx];
    }

    public void setWeight(int idx, float val)
    {
        _weights[idx] = val;
    }

    public float getAccWeight(int idx)
    {
        return _accWeights[idx];
    }

    public void setAccWeight(int idx, float val)
    {
        _accWeights[idx] = val;
    }

    public float getPreviousWeightDelta(int idx)
    {
        return _previousWeightDeltas[idx];
    }

    public void setPreviousWeightDelta(int idx, float val)
    {
        _previousWeightDeltas[idx] = val;
    }

    public float getWeightGradient(int idx)
    {
        return _weightGradients[idx];
    }

    public void setWeightGradient(int idx, float val)
    {
        _weightGradients[idx] = val;
    }

    public float getSumGradient()
    {
        return _sumGradient;
    }

    public void setSumGradient(float val)
    {
        _sumGradient = val;
    }

    public float getOutput()
    {
        return _output;
    }

    public void setOutput(float value)
    {
        _output = value;
    }
}
